#include "Inventory.hh"

// 返回物品列表的引用（可修改）
// Return a reference to the items vector (modifiable)
std::vector<Item>& Inventory::getItems(){
    return items;
}

// 返回物品列表的常量引用（只读）
// Return a const reference to the items vector (read-only)
const std::vector<Item>& Inventory::getItems() const{
    return items;
}

void Inventory::addItem(const Item& item) {
    items.push_back(item);
    std::cout << "Get item: [" << item.name << "] - " << item.description << "\n";
}

void Inventory::showItems() const {
    if (items.empty()) {
        std::cout << "No items in inventory.\n";
        return;
    }
    for (const auto& item : items) {
        std::cout << "- " << item.name << ": " << item.description << "\n";
    }
}

bool Inventory::isEmpty() const {
    return items.empty();
}
